/*****************************************************************************
 *   Copyright 2005 Tim A Wang
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 ****************************************************************************/
package com.jb.database.metamodel;

import java.sql.ResultSet;
import java.sql.SQLException;


public class Procedure extends BaseDatabaseEntity {
    String catalog;
    String name;
    String remarks;
    String schema;
    int type;

    public void setCatalog(String catalog) {
        this.catalog = catalog;
    }

    public String getCatalog() {
        return catalog;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setSchema(String schema) {
        this.schema = schema;
    }

    public String getSchema() {
        return schema;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public void assign(ResultSet crs) throws SQLException {
        setCatalog(crs.getString(1));
        setSchema(crs.getString(2));
        setName(crs.getString(3));
        setRemarks(crs.getString(12));
        setType(crs.getInt(6));

        /*
        PROCEDURE_CAT String => procedure catalog (may be null)
        PROCEDURE_SCHEM String => procedure schema (may be null)
        PROCEDURE_NAME String => procedure name
        COLUMN_NAME String => column/parameter name
        COLUMN_TYPE Short => kind of column/parameter:
        procedureColumnUnknown - nobody knows procedureColumnIn - IN parameter procedureColumnInOut - INOUT parameter procedureColumnOut - OUT parameter procedureColumnReturn - procedure return value procedureColumnResult - result column in ResultSet
        DATA_TYPE int => SQL type from java.sql.Types
        TYPE_NAME String => SQL type name, for a UDT type the type name is fully qualified
        PRECISION int => precision
        LENGTH int => length in bytes of data SCALE short => scale
        RADIX short => radix
        NULLABLE short => can it contain NULL. procedureNoNulls - does not allow NULL values procedureNullable - allows NULL values procedureNullableUnknown - nullability unknown
        REMARKS String => comment describing parameter/column
        */
    }
}
